#include <OSA.h>

#ifdef __OSAPICC__
#include <pic.h>
#endif

#ifdef __OSAPICC18__
#include <pic18.h>
#endif

#ifdef __OSAMCC18__
#include <p18f242.h>
#endif

#ifdef __OSACSS18__
#include <18F242.H>
#endif

unsigned char counter;

bank1 char a, b;

//------------------------------------------------------------------------------
void Task_T9 (void)
{
    for (;;)
    {
LABEL_START:
        OS_Bsem_Set(0);
        OS_Bsem_Set(1);
        OS_Bsem_Set(2);
        OS_Yield();

    }
}


//------------------------------------------------------------------------------
void Task_T0 (void)
{for (;;) {
    OS_Bsem_Wait(0);
    counter++;
}}

//------------------------------------------------------------------------------
void Task_T1 (void)
{for (;;) {
    OS_Bsem_Wait(1);
    counter++;
}}

//------------------------------------------------------------------------------
void Task_T2 (void)
{for (;;) {
    OS_Bsem_Wait(2);
    counter++;
}}

//------------------------------------------------------------------------------
void Task_T3 (void)
{for (;;) {
    OS_Bsem_Wait(2);
    counter++;
}}

//------------------------------------------------------------------------------
void Task_T4 (void)
{for (;;) {
    OS_Bsem_Wait(2);
    counter++;
}}

//------------------------------------------------------------------------------
void Task_T5 (void)
{for (;;) {
    OS_Bsem_Wait(2);
    counter++;
}}

//------------------------------------------------------------------------------
void Task_T6 (void)
{for (;;) {
    OS_Bsem_Wait(2);
    counter++;
}}

//------------------------------------------------------------------------------
void Task_T7 (void)
{for (;;) {
    OS_Bsem_Wait(2);
    counter++;
}}

//------------------------------------------------------------------------------
void Task_T8 (void)
{for (;;) {
    OS_Bsem_Wait(2);
    counter++;
}}

//------------------------------------------------------------------------------

void main (void)
{
    char cTestMode;

    OS_Init();

    cTestMode = 1;

    switch (cTestMode)
    {
    case 1:
        OS_Task_Create(2, Task_T0);
        OS_Task_Create(0, Task_T1);
        OS_Task_Create(2, Task_T2);
        OS_Task_Create(5, Task_T3);
        OS_Task_Create(3, Task_T4);
        OS_Task_Create(2, Task_T5);
        OS_Task_Create(6, Task_T6);
        OS_Task_Create(1, Task_T7);
        OS_Task_Create(4, Task_T8);
        OS_Task_Create(7, Task_T9);
        break;

    case 2:
        OS_Task_Create(1, Task_T0);
        OS_Task_Create(1, Task_T1);
        OS_Task_Create(1, Task_T2);
        OS_Task_Create(1, Task_T3);
        OS_Task_Create(1, Task_T4);
        OS_Task_Create(1, Task_T5);
        OS_Task_Create(1, Task_T6);
        OS_Task_Create(1, Task_T7);
        OS_Task_Create(1, Task_T8);
        OS_Task_Create(1, Task_T9);
        break;

    case 3:
        OS_Task_Create(0, Task_T0);
        OS_Task_Create(0, Task_T1);
        OS_Task_Create(0, Task_T2);
        OS_Task_Create(0, Task_T3);
        OS_Task_Create(0, Task_T4);
        OS_Task_Create(0, Task_T5);
        OS_Task_Create(0, Task_T6);
        OS_Task_Create(0, Task_T7);
        OS_Task_Create(0, Task_T8);
        OS_Task_Create(0, Task_T9);
        break;
    }

    for (;;)
    {
        OS_CLRWDT();
        OS_Sched();
    }
}

